package cn.edu.scau.cmi.dengzejun.chapter09;

import java.util.*;

public class Example9_15 {
	public static void main(String args[]) {
		Calendar calendar =  Calendar.getInstance();
		calendar.setTime(new Date());
		String year = String.valueOf(calendar.get(Calendar.YEAR)),
				month = String.valueOf(calendar.get(Calendar.MONTH)+1),
				day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
		int hour = calendar.get(Calendar.HOUR_OF_DAY),
			minute = calendar.get(Calendar.MINUTE),
			second = calendar.get(Calendar.SECOND);
		System.out.print("the time is ");
		System.out.print(" " + year +" / " + month +" / " + day);
		System.out.println(" " + hour +" : " + minute +" : "+ second);
		int temp_year = 1949 , temp_month = 9 , temp_day = 1;
		calendar.set(temp_year, temp_month-1,temp_day);
		long time_1 = calendar.getTimeInMillis();
		temp_year = 2009;
		temp_month = 9;
		temp_day = 1;
		calendar.set(temp_year, temp_month-1, temp_day);
		long time_2 = calendar.getTimeInMillis();
		long  separated = (time_2-time_1)/(1000*60*60*24);
		System.out.println("the days between 2009-10-1 and 1949-10-1 are " + separated +" days ");
		return;
	}
}
